<template>
	<div id="app">
		<router-view/>
	</div>
</template>

<script>
	import { routerArr } from '@/router/index';
	import { mapMutations } from 'vuex';

	export default {
		name: 'App',
		data() {
			return {}
		},
		created() {
			this.init();
		},
		mounted() {
			let box = document.getElementById('firstLoad');
			document.body.removeChild(box); //移除首屏loading
		},
		methods: {
			...mapMutations(['NAVLIST']),
			init() {
				//console.log(routerArr)
				let navList = routerArr.map((x, indexX) => {
					x.children = x.children.map((y, indexY) => {
						return {
							icon: y.icon,
							meta: y.meta,
							path: y.path,
						}
					});
					return {
						icon: x.icon,
						meta: x.meta,
						path: x.path,
						children: x.children,
					}
				});
				this.NAVLIST(navList);
				/*this.$router.options.routes.push({
					path: '*',
					redirect: '/404'
				});*/
				//this.$router.addRoutes(this.$router.options.routes); //动态添加路由
			},
		}
	}
</script>

<style>
	#app {
		width: 100%;
		height: 100vh;
		overflow: hidden;
		background: #fff;
	}
</style>